package com.park.web.controller.admin;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.park.client.model.user.VisitInfoModel;
import com.park.client.service.user.VisitInfoService;
import com.park.common.util.Page;
import com.park.common.util.PageData;
import com.park.web.contant.Global;
import com.park.web.controller.BaseController;

@Controller
@RequestMapping("/admin/log/visit")
public class AdminVisitController extends BaseController{

	@Autowired
	private VisitInfoService visitInfoService;
	
	@RequestMapping("listRows")
	@ResponseBody
	public PageData<VisitInfoModel> listRows(Integer rows,@RequestParam(name="page",defaultValue="1")Integer pageNow,HttpServletRequest request){
		PageData<VisitInfoModel> pageData = new PageData<>();
		VisitInfoModel visitInfo = new VisitInfoModel();
		Integer total = visitInfoService.selectTotal(visitInfo);
		Page page = new Page(pageNow,total,rows);
		visitInfo.setStartPos(page.getStartPos());
		visitInfo.setPageSize(page.getPageSize());
		List<VisitInfoModel> list = visitInfoService.selectPagination(visitInfo);
		pageData.setTotal(total);
		pageData.setRows(list);
		return pageData;
	}
	
	/*访问者日志页面*/
	@RequestMapping("visitList")
	public String visitList(HttpServletRequest request){
			return Global.ADMIN_PATH+"log/visit/visitList";
	}
	
}
